package Class_Controller;


import static com.sun.corba.se.spi.presentation.rmi.StubAdapter.request;
import java.io.Serializable;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author thien_000
 */
import java.sql.*;

public class bean_login implements Serializable {

    public bean_login() {
    }

    public boolean checkLogin(String username, String password) {
        Connection con = null;
        ResultSet rs = null;
        String userName = "root";
        String passWord = "";
        try {
            String url = "jdbc:mysql://localhost:3306/logindb?useUnicode=true&characterEncoding=UTF-8";
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            con = DriverManager.getConnection(url, userName, passWord);
            String sql = "SELECT * FROM tbltaikhoan WHERE UserName=? and PassWord=?";
            PreparedStatement stm = con.prepareStatement(sql);
            stm.setString(1, username);
            stm.setString(2, password);
            rs = stm.executeQuery();
            boolean result = rs.next();
            stm.close();
            rs.close();
            con.close();
            if (result) {
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
}
